/*
 * JOY电子商务网运营事业部
 * 中国移动通信集团设计院有限公司
 * B2BJOY.COM  OPERATION  DIVISION
 * China Mobile Group Design Institute Co., Ltd
 */

package com.uhaou.system.dao.impl; 
import com.uhaou.system.dao.ISysFunctionDao;
import org.springframework.stereotype.Repository;

import java.util.*;

import org.apache.commons.lang.StringUtils;

import com.uhaou.common.base.*;
import com.uhaou.common.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.uhaou.system.model.*;
import com.uhaou.system.dao.*;
import com.uhaou.system.service.*;
import com.uhaou.system.vo.query.*;
import com.uhaou.system.model.SysFunction;

/**
 * @author  jiangcheng
 * @version 1.0
 * @since 1.0
 */




@Repository("sysFunctionDao")
public class SysFunctionDaoImpl extends BaseIbatisDao<SysFunction,java.lang.String> implements ISysFunctionDao{
	
	@Override
	public String getIbatisSqlMapNamespace() {
		return "SysFunction";
	}
	
	public SysFunction getById(java.lang.String id){
		return super.getById( id);
	}
	
	public void deleteById(java.lang.String id){
		super.deleteById(id);
	}
	
	/** 插入数据 */
	public void save(SysFunction entity){
		if(StringUtils.isEmpty(entity.getId())) {
			entity.setId(IdGenerator.genUUIDStr());
		}
		super.save(entity);
	}
	
	/** 更新数据 */
	public void update(SysFunction entity){
		super.update(entity);
	}

	public boolean isUnique(SysFunction entity, String uniquePropertyNames){
		return super.isUnique( entity, uniquePropertyNames);
	}
	
	public List<SysFunction> findAll(){
		return super.findAll();
	}
	
	public void saveOrUpdate(SysFunction entity) {
		if(StringUtils.isEmpty(entity.getId())) {
			entity.setId(IdGenerator.genUUIDStr());
			super.save(entity);
		}
		else 
			super.update(entity);
	}
	
	public Page findPage(SysFunctionQuery query) {
		return pageQuery("SysFunction.findPage",query);
	}
	/**
	 * 根据父权限编码获得所有子节点权限（包括子权限的子权限）
	 * @param SysFunctionQuery query
	 * @return List<SysFunction>
	 * add by jiangcheng
	 */
	public List<SysFunction> getFuncnodeList(SysFunctionQuery query) {
		System.out.print("NDY");
	    try{
		List list = (List) getSqlMapClientTemplate().queryForList("SysFunction.getFuncnode", query);
		System.out.print(list);
		return list;
	    }catch(Exception e){
	    	System.out.print(e);
	    	return null;
	    }
	}
	
	/**
	 * 查询用户所拥有的权限
	 * jiangcheng
	 */
	public List<SysFunction> getUserFunc(String userId) {
		List <SysFunction> funcList = getSqlMapClientTemplate().queryForList("SysFunction.findByuserId",userId);
		return funcList;
	}

}
